using DynamicChart.Model;
using DynamicChart.Repository;
using DynamicChart.Util;

namespace DynamicChart.Service;

public class ScreenChartService
{
    private readonly AppDbContext _context;
    
    public ScreenChartService(AppDbContext context)
    {
        _context = context;
    }
    
    public ScreenChartModel LoadScreenChartModel(int id)
    {
        return _context.ScreenChartModel.First(it => it.Id == id);
    }

    public ScreenChartModel Save(ScreenChartModel screenChartModel)
    {
        ScreenChartModel screenChartModel1 = _context.ScreenChartModel.Add(screenChartModel).Entity;
        _context.SaveChanges();
        return screenChartModel1;
    }
}